/*
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2025-06-22 12:09:47
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-23 08:39:01
 * @FilePath: \shangyitong\src\store\modules\hospitalDetail.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineStore } from "pinia";
import { reqHospitalDetail, reqHospitalDeparment } from '@/api/hospital'
import type { HospitalDetailResponseData, HospitalDetail, DeparmentResponseData } from '@/api/hospital/type'
import type { DetailState, } from './type/type'
//pinia 仓库写法:组合式API和选项是API都可以
const useDetailStore = defineStore('Detail', {
    state: (): DetailState => {
        return {
            //存储一样详情数据
            hospitalDetail: ({}) as HospitalDetail,
            //存储医院科室数据
            deparmentArr: []
        }
    },
    actions: {
        async getHospital(hosCode: string) {
            let result: HospitalDetailResponseData = await reqHospitalDetail(
                hosCode
            )
            if (result.code == 200) {
                this.hospitalDetail = result.data
            }
        },
        async getDeparment(hosCode: string) {
            let result: DeparmentResponseData = await reqHospitalDeparment(hosCode)
            if (result.code == 200) {
                this.deparmentArr = result.data;
            }
        }
    },
    getters: {

    },
    // 启用持久化配置
    persist: true,
})
//获取仓库的方法对外暴露
export default useDetailStore